<?php
/**
 * @version     1.0.0
 * @package     com_events
 * @copyright   Copyright (C) 2013. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 * @author      JORGE EDUARDO DE O LIVEIRA LUCIANO <jeolcavaco@hotmail.com> - http://jorgeeduardo.wordpress.com
 */
// no direct access
defined('_JEXEC') or die;
?>
<script type="text/javascript">
    function deleteItem(item_id){
        if(confirm("<?php echo JText::_('COM_EVENTS_DELETE_MESSAGE'); ?>")){
            document.getElementById('form-evento-delete-' + item_id).submit();
        }
    }
</script>

<div class="eventos container">
	<h3>Eventos</h3>
   
		<?php $show = false; ?>
        <?php 
        foreach ($this->items as $item) : 

        	$dia = substr($item->datestart, 8, 2) ;
       	 	$mes = substr($item->datestart, 5, 2) ;
       	 	$ano = substr($item->datestart, 0, 4) ;
       	 	$hora = substr($item->hourstart, 0, 5) ;
       	 	               
			if($item->state == 1 || ($item->state == 0 && JFactory::getUser()->authorise('core.edit.own',' com_events.evento.'.$item->id))):
				$show = true;
		?>
			<div class="b">
				<span>dia <?php echo $dia .'/'.$mes.'/'.$ano .' - '. $hora .'h';?></span>
				<span>local: <?php echo $item->local;?></span>
				<span>responsável: <?php echo $item->owner; ?></span>	
				<span><?php echo $item->title;?></span>
				<span class="intro"><?php echo $item->intro;?></span>
				
				<?php 
				if(strip_tags($item->content) !=''){
					if(strlen(strip_tags($item->content)) > 120)
						echo  '<p>'.substr(strip_tags($item->content), 0, 120).'...</p>'; 
					else 
						echo '<p>'.strip_tags($item->content).'</p>';
				}
					?>	
					
				<a href="<?php echo JRoute::_('index.php?option=com_events&view=evento&id=' . (int)$item->id); ?>">Leia mais...</a>
			</div>
			<?php endif; ?>
		
		<?php endforeach; ?>
        <?php
        if (!$show):
        ?>
        <div class="b">
            Não existem eventos cadastrados.
            </div>
            <?php 
        endif;        
        ?>   
        
</div>


<?php if ($this->pagination->getPagesCounter()): ?>
    <div class="pagination">
        <p class="counter">
            <?php echo $this->pagination->getPagesCounter(); ?>
        </p>
        <?php echo $this->pagination->getPagesLinks(); ?>
    </div>
<?php endif; ?>

